home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / unix / c / putenv < prev    next >
Text File  |  1996-11-09  |  1KB  |  56 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/putenv,v $
  4.  * $Date: 1996/05/06 09:01:35 $
  5.  * $Revision: 1.2 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: putenv,v $
  10.  * Revision 1.2  1996/05/06 09:01:35  unixlib
  11.  * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
  12.  * Saved for 3.7a release.
  13.  *
  14.  * Revision 1.1  1996/04/19 21:35:27  simon
  15.  * Initial revision
  16.  *
  17.  ***************************************************************************/
  18.  
  19. static const char rcs_id[] = "$Id: putenv,v 1.2 1996/05/06 09:01:35 unixlib Rel $";
  20.  
  21. #include <stdlib.h>
  22. #include <string.h>
  23.  
  24. #include <sys/os.h>
  25. #include <sys/unix.h>
  26. #include <sys.swis.h>
  27.  
  28. int
  29. putenv (register char *s)
  30.  
  31. {
  32.   register char *v;
  33.   int r[10];
  34.   _kernel_oserror *e;
  35.  
  36.   if (!(v = strchr (s, '=')))
  37.     return (-1);
  38.  
  39.   __addenv (s, 0);
  40.  
  41.   *v++ = 0;
  42.   r[0] = (int) s;
  43.   r[1] = (int) v;
  44.   r[2] = strlen (v);
  45.   r[3] = 0;
  46.   r[4] = 0;
  47.   e = os_swi (OS_SetVarVal, r);
  48.   *--v = '=';
  49.   if (e)
  50.     {
  51.       __seterr (e);
  52.       return (-1);
  53.     }
  54.   return (0);
  55. }
  56.